<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<title>${ticket_name}明细</title>
<c:choose>
	 <c:when test="${os eq 'wechat'|| os eq 'web'}">
	 	<link rel="stylesheet"  href="${host_url}/css/app/common.css">
		<link rel="stylesheet"  href="${host_url}/css/app/coupon_details.css">
		<link rel="stylesheet"  href="${host_url}/css/app/dropload.css">
		<script src="${host_url}/js/app/jquery.min.js"></script>
		<script src="${host_url}/js/app/commonForWe.js"></script>
	 	<script src="${host_url}/js/app/dropload.min.js"></script>
		
	 </c:when>
	 <c:otherwise>
		<link rel="stylesheet"  href="/css/app/common.css">
		<link rel="stylesheet"  href="/css/app/coupon_details.css">
		<link rel="stylesheet"  href="/css/app/dropload.css">
		<script src="/js/app/jquery.min.js"></script>
		<script src="/js/app/common.js"></script>
		<script src="/js/app/dropload.min.js"></script>
	 </c:otherwise>
</c:choose>


<script type="text/javascript">
  document.getElementsByTagName('html')[0].style.fontSize = document.documentElement.clientWidth/50 + 'px';
</script> 
<script type="text/javascript">
var os="${os}";
<c:if test="${os=='wechat'||os=='web'}">

	function getList(type,bill_type){
			$.ajax({
				type:"GET", 	
				url:'ticketsList.do?type='+type+"&bill_type="+bill_type,	 		

				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					$("#we_body").html(data);
					var page_index_select = 2;	/* 筛选 */
					loadPagination("listSelect",page_index_select,"logSelect",bill_type,type);
				 },	 
			});
		}
		
		$(function(){
			$.ajax({
				type:"GET", 	
				url:'ticketsItem.do?bill_type=2',	 		
				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					if($.trim(data)){
						$("#logIn").html(data);  
					}else{
						$("#listInBlank").html('<div class="zanwu"> <span><img src="/img/app/zanwu.png"></span> <p>暂无记录</p> </div>');
					}
				 },	 
			});
			
			$.ajax({
				type:"GET", 	
				url:'ticketsItem.do?bill_type=1',	 		
				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					if($.trim(data)){
						$("#logOut").html(data);  
					}else{
						$("#listOutBlank").html('<div class="zanwu"> <span><img src="/img/app/zanwu.png"></span> <p>暂无记录</p> </div>');
					}
				 },	 
			});
		});
		
		

	 $(function(){
		/*  页数 */
		var page_index_all = 2; /* 全部 */
		var page_index_in = 2;	/* 收入 */
		var page_index_out = 2;	/* 支出 */
		
	    loadPagination("listAll",page_index_all,"logAll","","");
	    loadPagination("listIn",page_index_in,"logIn",2,"");
	    loadPagination("listOut",page_index_out,"logOut",1,"");
	});	

	function loadPagination(div_id, page_index, ul_id, bill_type, type){
		$('#'+div_id).dropload({
	        scrollArea : window,
	        loadDownFn : function(me){
	            $.ajax({
	                type: 'get',
	                url: 'ticketsItem.do?page_index='+page_index+"&bill_type="+bill_type+"&type="+type,
	                dataType: 'text',
	                beforeSend: function(request) {
	    				request.setRequestHeader("AUTHORIZATION","${token}");
	    				request.setRequestHeader("SECRET","${memberId}");
	    				request.setRequestHeader("OS","${os}");
	    			 }, 
	                contentType:"application/x-www-form-urlencoded; charset=UTF-8",
	                success: function(msg){
	                    if($.trim(msg)){
	                		page_index++;
	                    	$("#"+ul_id).append(msg);
	                    	me.resetload();
	                    	/* 如果没有数据 */
	                    } else{
	                        /* 锁定 */
	                        me.lock();
	                        /* 无数据 */
	                        me.noData();
	                        $("#"+div_id+" .dropload-load").html("");
	                    } 
	                },
		                error: function(xhr, type){
	                    /* 即使加载出错，也得重置 */
	                    me.resetload();
	                } 
	            });
	        }
	    });
	} 
	 </c:if>
	 <c:if test="${os=='ios' || os=='android'}">
	/* ios  android */
	function fn_goTicketsLogOne(id){ 
		var ticketslogone_url=$("#ticketslogone_url").val();
		window.webkit.messageHandlers.ios_open_page.postMessage('WKViewController:::url->'+ticketslogone_url+'?logticket_id='+id+':::webTitle->交易明细:::isRefresh->YES');
	}

	function getList(type,bill_type){
			$.ajax({
				type:"GET", 	
				url:'ticketsList?type='+type+"&bill_type="+bill_type,	 		

				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					$("body").html(data);  
					var page_index_select = 2;	/* 筛选 */
					loadPagination("listSelect",page_index_select,"logSelect",bill_type,type);
				 },	 
			});
		}
		
		$(function(){
			$.ajax({
				type:"GET", 	
				url:'ticketsItem?bill_type=2',	 		
				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					if($.trim(data)){
						$("#logIn").html(data);  
					}else{
						$("#listInBlank").html('<div class="zanwu"> <span><img src="/img/app/zanwu.png"></span> <p>暂无记录</p> </div>');
					}
				 },	 
			});
			
			$.ajax({
				type:"GET", 	
				url:'ticketsItem?bill_type=1',	 		
				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					if($.trim(data)){
						$("#logOut").html(data);  
					}else{
						$("#listOutBlank").html('<div class="zanwu"> <span><img src="/img/app/zanwu.png"></span> <p>暂无记录</p> </div>');
					}
				 },	 
			});
		});
		
		

	 $(function(){
		/* 页数 */
		var page_index_all = 2; /* 全部 */
		var page_index_in = 2;	/* 收入 */
		var page_index_out = 2;	/* 支出 */
	    loadPagination("listAll",page_index_all,"logAll","","");
	    loadPagination("listIn",page_index_in,"logIn",2,"");
	    loadPagination("listOut",page_index_out,"logOut",1,"");
	});	

	function loadPagination(div_id, page_index, ul_id, bill_type, type){
		$('#'+div_id).dropload({
	        scrollArea : window,
	        loadDownFn : function(me){
	            $.ajax({
	                type: 'get',
	                url: 'ticketsItem?page_index='+page_index+"&bill_type="+bill_type+"&type="+type,
	                dataType: 'text',
	                beforeSend: function(request) {
	    				request.setRequestHeader("AUTHORIZATION","${token}");
	    				request.setRequestHeader("SECRET","${memberId}");
	    				request.setRequestHeader("OS","${os}");
	    			 }, 
	                contentType:"application/x-www-form-urlencoded; charset=UTF-8",
	                success: function(msg){
	                    if($.trim(msg)){
	                		page_index++;
	                    	$("#"+ul_id).append(msg);
	                    	me.resetload();
	                    /* 如果没有数据 */
	                    } else{
	                    /*    锁定 */
	                        me.lock();
	                        /* 无数据 */
	                        me.noData();
	                        $("#"+div_id+" .dropload-load").html("");
	                    } 
	                },
		                error: function(xhr, type){
	                   /*  即使加载出错，也得重置 */
	                    me.resetload();
	                } 
	            });
	        }
	    });
	} 
	</c:if>


</script>
</head>
<body>
<c:if test="${'wechat'==os ||'web'==os}">
	<div id="we_body">
</c:if>
<input type="hidden" id="ticketslogone_url" value="${ticketslogone_url}">
    <div id="main">
        <div class="tab">
            <ul class="menu-group-center">
                <li class="on">全部</li>
                <li>收入</li>
                <li>支出</li>
                <p class="btn-popup"><span class="btn-popup">筛选</span></p>
            </ul>
            <div class="content" id="listAll">
                <ul id="logAll">
               	 	<c:forEach items="${ticketLogList}" var="c">
	                    <c:if test="${c.type!=4}">
		                    <c:if test="${'ios'==os}">
					        	 <li class="clearfix" onclick="fn_goTicketsLogOne(${c.logticket_id})">
					        </c:if>
					    	<c:if test="${'wechat'==os ||'web'==os}">
					            <li class="clearfix" onclick="goTicketsLogOneForWE(${c.logticket_id})">
					        </c:if>
					    	<c:if test="${'android'==os}">
					            <li class="clearfix" onclick="android.startUrl('交易明细','${ticketslogone_url}','logticket_id->${c.logticket_id}')">
					        </c:if>
		                        <p class="leftArea">
		                            <span>${c.type_name}<c:if test="${c.type == 2}">&nbsp;（订单号：${c.order_no}）</c:if></span><br>
		                           	 <fmt:parseDate value=" ${c.create_time}" var="date" pattern="yyyy-MM-dd HH:mm:ss"/>  
									 <span><fmt:formatDate value="${date}" pattern="yyyy-MM-dd HH:mm" /></span>
		                        </p>
		                        <p class="rightArea <c:if test="${c.bill_type == 2}">col-arresting</c:if>">${c.num}</p>
		                    </li>    
	                   </c:if>           	 	     
                	</c:forEach>	    
                </ul>
                <c:if test="${ticketLogList.size()==0}">
					<div class="zanwu">
						  <span><img src="${host_url}/img/app/zanwu.png"></span>
						  <p>暂无记录</p>
					</div>
				</c:if> 
            </div>
            <div class="content"  id="listIn" style="display: none;"><ul id="logIn"></ul>
	 			<div id="listInBlank">
					 
				</div>
 			</div>        
            <div class="content"  id="listOut" style="display: none;"><ul id="logOut"></ul>
	            <div id="listOutBlank">
					   
				</div>
            </div>
        </div>
    </div>
 	<div class="bg-popup"></div>
    <div id="popup">
        <div class="popup-content">
            <div class="clearfix"><h4 class="leftArea"><span>请选择您要筛选的分类</span></h4><p class="rightArea"><span>筛选</span></p></div>
            <ul class=" one whole common ">
                <li class="whole-one"><span>全部</span></li>
                <li><span>收入</span></li>
                <li><span>支出</span></li>
            </ul>
            <ul class="show-content">
                <li class="whole-one" onclick="getList('','')"><span>全部</span></li>
                <li class="whole-two" onclick="getList('',2)"><span>收入</span></li>
                <li class="whole-there" onclick="getList('',1)"><span>支出</span></li>
            </ul>
            <ul class="show-content">
                <li class="whole-one" onclick="getList(1,2)"><span>${ticket_name}充值</span></li>
                <li class="whole-one" onclick="getList(5,2)"><span>退款</span></li>
            </ul>
            <ul class="show-content">
                <li class="whole-one" onclick="getList(3,1)"><span>${ticket_name}售出</span></li>
                <li class="whole-one" onclick="getList(2,1)"><span>购物</span></li>
            </ul>
        </div>
    </div>
 <c:if test="${'wechat'==os ||'web'==os}">
  	</div>
 </c:if>
</body>
</html>